using GLib;
//using Gee;

namespace Rob
{
	namespace Rules
	{
		class Time: Rob.Rules.Rule
		{
			private string _name;
			private string _title;
			private int starttime;
			private int endtime;
			private bool[] days;
			
			construct
			{
				days = new bool[ 7 ];
				for(int i = 0; i <7; i++)
					days[ i ] = false;
				starttime = 0;
				endtime = 24*60;
				_title = "";
				_name = "";
			}	
			
			public string title
			{
				get{return _title;}
				set{_title = value;}
			}
			public string name
			{
				get{return _name;}
				set{_name = value;}
			}	
			public override bool check()
			{
				GLib.TimeVal tv= GLib.TimeVal();
				tv.get_current_time();
				GLib.Date date = GLib.Date();
				date.set_time_val(tv);
				stdout.printf("%i\n", date.get_weekday());

				return days[ date.get_day() ];
			}
			public override bool read_config(GLib.KeyFile kf, string name)
			{
				try
				{
					this.name = name;
					title = kf.get_string(name, "title");	
					days[ (int) GLib.DateWeekday.MONDAY ] = kf.get_boolean(name, "monday");
					days[ (int) GLib.DateWeekday.TUESDAY ] = kf.get_boolean(name, "tuesday");
					days[ (int) GLib.DateWeekday.WEDNESDAY ] = kf.get_boolean(name, "wednesday");
					days[ (int) GLib.DateWeekday.THURSDAY ] = kf.get_boolean(name, "thursday");
					days[ (int) GLib.DateWeekday.FRIDAY ] = kf.get_boolean(name, "friday");
					days[ (int) GLib.DateWeekday.SATURDAY ] = kf.get_boolean(name, "saturday");
					days[ (int) GLib.DateWeekday.SUNDAY ] = kf.get_boolean(name, "sunday");
				}

				catch( GLib.KeyFileError kfe)
				{
					return false;
				}
				return true;
			}
			public override bool save(GLib.KeyFile kf)
			{
				return false;	
			}
			

		}
		
	}
}
